package dom

/**
DOM Core Level 3
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-BBACDC08
*/

// ExceptionCode
const (
	INDEX_SIZE_ERR = uint16(iota + 1)
	DOMstring_SIZE_ERR
	HIERARCHY_REQUEST_ERR
	WRONG_DOCUMENT_ERR
	INVALID_CHARACTER_ERR
	NO_DATA_ALLOWED_ERR
	NO_MODIFICATION_ALLOWED_ERR
	NOT_FOUND_ERR
	NOT_SUPPORTED_ERR
	INUSE_ATTRIBUTE_ERR
	INVALID_STATE_ERR        // Introduced in DOM Level 2
	SYNTAX_ERR               // Introduced in DOM Level 2
	INVALID_MODIFICATION_ERR // Introduced in DOM Level 2
	NAMESPACE_ERR            // Introduced in DOM Level 2
	INVALID_ACCESS_ERR       // Introduced in DOM Level 2
	VALIDATION_ERR           // Introduced in DOM Level 3
	TYPE_MISMATCH_ERR        // Introduced in DOM Level 3
)
/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-17189187
*/
type DOMException interface {
	Code() uint16
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMstringList
*/
type DOMStringList interface {
	Item(index uint64) string
	Length() uint64
	Contains(str string) bool
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#NameList
*/
type NameList interface {
	GetName(index uint64) string
	GetNamespaceURI(index uint64) string
	Length() uint64
	Contains(str string) bool
	ContainsNS(namespaceURI, name string) bool
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMImplementationList
*/
type DOMImplementationList interface {
	Item(index uint64) DOMImplementation
	Length() uint64
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMImplementationSource
*/
type DOMImplementationSource interface {
	GetDOMImplementation(features string) DOMImplementation
	GetDOMImplementationList(features string) DOMImplementationList
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-102161490
*/
type DOMImplementation interface {
	HasFeature(feature, version string) bool
	CreateDocumentType(qualifiedName, publicId, systemId string) (DocumentType, DOMException)         //Introduced in DOM Level 2
	CreateDocument(namespaceURI, qualifiedName string, doctype DocumentType) (Document, DOMException) // Introduced in DOM Level 3
	GetFeature(feature, version string) DOMObject                                                     // Introduced in DOM Level 3
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-B63ED1A3
*/
type DocumentFragment interface {
	Node
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#i-Document
*/
type Document interface {
	Node
	Doctype() DocumentType // Modified in DOM Level 3
	Implementation() DOMImplementation
	DocumentElement() Element
	CreateElement() (Element, DOMException)
	CreateDocumentFragment() DocumentFragment
	CreateTextNode(data string) Text
	CreateComment(data string) Comment
	CreateCDATASection(data string) (CDATASection, DOMException)
	CreateProcessingInstruction(target, data string) (ProcessingInstruction, DOMException)
	CreateAttribute(name string) (Attr, DOMException)
	CreateEntityReference(name string) (EntityReference, DOMException)
	GetElementsByTagName(tagname string) NodeList
	ImportNode(importedNode Node, deep bool) (Node, DOMException)                  // Modified in DOM Level 2
	CreateElementNS(namespaceURI, qualifiedName string) (Element, DOMException) // Introduced in DOM Level 2
	CreateAttributeNS(namespaceURI, qualifiedName string) (Attr, DOMException)  // Introduced in DOM Level 2
	GetElementsByTagNameNS(namespaceURI, localName string) NodeList             // Introduced in DOM Level 2
	GetElementById(elementId string) Element                                    // Introduced in DOM Level 2
	InputEncoding() string                                                      // Introduced in DOM Level 3
	XmlEncoding() string                                                        // Introduced in DOM Level 3
	XmlStandalone() bool                                                           // Introduced in DOM Level 3
	SetXmlStandalone(bool) DOMException                                            // Introduced in DOM Level 3
	XmlVersion() string                                                         // Introduced in DOM Level 3
	SetXmlVersion(string) DOMException                                          // Introduced in DOM Level 3
	StrictErrorChecking() bool                                                     // Introduced in DOM Level 3
	SetStrictErrorChecking(bool)                                                   // Introduced in DOM Level 3
	DocumentURI() string                                                        // Introduced in DOM Level 3
	SetDocumentURI(string)                                                      // Introduced in DOM Level 3
	AdoptNode(source Node) (Node, DOMException)                                    // Introduced in DOM Level 3
	DomConfig() DOMConfiguration                                                   // Introduced in DOM Level 3
	NormalizeDocument()                                                            // Introduced in DOM Level 3
	RenameNode(n Node, namespaceURI, qualifiedName string) (Node, DOMException) // Introduced in DOM Level 3
}

// NodeType
const (
	ELEMENT_NODE                = uint16(iota + 1) // The node is an Element
	ATTRIBUTE_NODE                                 // The node is an Attr
	TEXT_NODE                                      // The node is a Text
	CDATA_SECTION_NODE                             // The node is a CDATASection
	ENTITY_REFERENCE_NODE                          // The node is an EntityReference
	ENTITY_NODE                                    // The node is an Entity
	PROCESSING_INSTRUCTION_NODE                    // The node is a ProcessingInstruction
	COMMENT_NODE                                   // The node is a Comment
	DOCUMENT_NODE                                  // The node is a Document
	DOCUMENT_TYPE_NODE                             // The node is a DocumentType
	DOCUMENT_FRAGMENT_NODE                         // The node is a DocumentFragment
	NOTATION_NODE                                  // The node is a notation
)
// DocumentPosition
const (
	DOCUMENT_POSITION_DISCONNECTED = uint16(1 << iota)
	DOCUMENT_POSITION_PRECEDING
	DOCUMENT_POSITION_FOLLOWING
	DOCUMENT_POSITION_CONTAINS
	DOCUMENT_POSITION_CONTAINED_BY
	DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
)
/* 
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1950641247
*/
type Node interface {
	NodeName() string
	NodeValue() (string, DOMException)
	SetNodeValue(newValue string) DOMException
	NodeType() uint16
	ParentNode() Node
	ChildNodes() NodeList
	FirstChild() Node
	LastChild() Node
	PreviousSibling() Node
	NextSibling() Node
	Attributes() NamedNodeMap                                  // Modified in DOM Level 2
	OwnerDocument() Document                                   // Modified in DOM Level 2
	InsertBefore(newChild, refChild Node) (Node, DOMException) // Modified in DOM Level 3 
	ReplaceChild(newChild, oldChild Node) (Node, DOMException) // Modified in DOM Level 3 
	RemoveChild(oldChild Node) (Node, DOMException)            // Modified in DOM Level 3 
	AppendChild(newChild Node) (Node, DOMException)            // Modified in DOM Level 3 
	HasChildNodes() bool
	CloneNode(deep bool) (Node, DOMException)
	Normalize()                                                                       // Modified in DOM Level 3 
	IsSupported(feature, version string) bool                                      // Introduced in DOM Level 2
	NamespaceURI() string                                                          // Introduced in DOM Level 2
	Prefix() string                                                                // Introduced in DOM Level 2
	SetPrefix(string) DOMException                                                 // Introduced in DOM Level 2
	LocalName() string                                                             // Introduced in DOM Level 2
	HasAttributes() bool                                                              // Introduced in DOM Level 2 	
	BaseURI() string                                                               // Introduced in DOM Level 3
	CompareDocumentPosition(other Node) (uint16, DOMException)                        // Introduced in DOM Level 3
	TextContent() (string, DOMException)                                           // Introduced in DOM Level 3
	SetTextContent(string) DOMException                                            // Introduced in DOM Level 3
	IsSameNode(other Node) bool                                                       // Introduced in DOM Level 3
	LookupPrefix(namespaceURI string) string                                    // Introduced in DOM Level 3
	IsDefaultNamespace(namespaceURI string) bool                                   // Introduced in DOM Level 3
	LookupNamespaceURI(prefix string) string                                    // Introduced in DOM Level 3
	IsEqualNode(arg Node) bool                                                        // Introduced in DOM Level 3
	GetFeature(feature, version string) DOMObject                                  // Introduced in DOM Level 3
	SetUserData(key string, data DOMUserData, handler UserDataHandler) DOMUserData // Introduced in DOM Level 3
	GetUserData(key string) DOMUserData                                            // Introduced in DOM Level 3
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-536297177
*/
type NodeList interface {
	Item(index uint64)
	Length() uint64
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1780488922
*/
type NamedNodeMap interface {
	GetNamedItem(name string) Node
	SetNamedItem(arg Node) (Node, DOMException)
	RemoveNamedItem(name string) (Node, DOMException)
	Item(index uint64) Node
	Length() uint64
	GetNamedItemNS(namespaceURI string, localName string) (Node, DOMException)    // Introduced in DOM Level 2
	SetNamedItemNS(arg Node) (Node, DOMException)                                       // Introduced in DOM Level 2
	RemoveNamedItemNS(namespaceURI string, localName string) (Node, DOMException) // Introduced in DOM Level 2
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-FF21A306
*/
type CharacterData interface {
	Node
	Data() (string, DOMException)
	SetData(string) DOMException
	Length() uint64
	SubstringData(offset, count uint64) (string, DOMException)
	AppendData(arg string) DOMException
	InsertData(offset uint64, arg string) DOMException
	DeleteData(offset, count uint64) DOMException
	ReplaceData(offset, count uint64, arg string) DOMException
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-637646024
*/
type Attr interface {
	Node
	Name() string
	Specified() bool
	Value() string
	SetValue(string) DOMException
	OwnerElement() Element    // Introduced in DOM Level 2
	SchemaTypeInfo() TypeInfo // Introduced in DOM Level 3
	IsId() bool               // Introduced in DOM Level 3
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-745549614
*/
type Element interface {
	Node
	TagName() string
	GetAttribute(name string)
	SetAttribute(name, value string) DOMException
	RemoveAttribute(name string) DOMException
	GetAttributeNode(name string) Attr
	SetAttributeNode(newAttr Attr) (Attr, DOMException)
	RemoveAttributeNode(oldAttr Attr) (Attr, DOMException)
	GetElementsByTagName(name string) NodeList
	GetAttributeNS(namespaceURI, localName string) (string, DOMException)        // Introduced in DOM Level 2
	SetAttributeNS(namespaceURI, qualifiedName, value string) DOMException          // Introduced in DOM Level 2
	RemoveAttributeNS(namespaceURI, localName string) DOMException                  // Introduced in DOM Level 2
	GetAttributeNodeNS(namespaceURI, localName string) (Attr, DOMException)         // Introduced in DOM Level 2
	SetAttributeNodeNS(newAttr Attr) (Attr, DOMException)                              // Introduced in DOM Level 2
	GetElementsByTagNameNS(namespaceURI, localName string) (NodeList, DOMException) // Introduced in DOM Level 2
	SchemaTypeInfo() TypeInfo                                                          // Introduced in DOM Level 3
	SetIdAttribute(name string, isId bool) DOMException                             // Introduced in DOM Level 3
	SetIdAttributeNS(namespaceURI, localName string, isId bool) DOMException        // Introduced in DOM Level 3
	SetIdAttributeNodeNS(idAttr Attr, isId bool) DOMException                          // Introduced in DOM Level 3
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1312295772
*/
type Text interface {
	Node
	SplitText(offset uint64) (Text, DOMException)
	IsElementContentWhitespace() bool                        // Introduced in DOM Level 3
	WholeText() string                                    // Introduced in DOM Level 3
	ReplaceWholeText(content string) (Text, DOMException) // Introduced in DOM Level 3
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1728279322
*/
type Comment interface {
	CharacterData
}

// DerivationMethods
const (
	DERIVATION_RESTRICTION = uint64(0x00000001 << iota)
	DERIVATION_EXTENSION
	DERIVATION_UNION
	DERIVATION_LIST
)
/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo
*/
// Introduced in DOM Level 3
type TypeInfo interface {
	TypeName() string
	TypeNamespace() string
	IsDerivedFrom(typeNamespaceArg, typeNameArg string, derivationMethod uint64) bool
}

// OperationType
const (
	NODE_CLONED = uint16(iota + 1)
	NODE_IMPORTED
	NODE_DELETED
	NODE_RENAMED
	NODE_ADOPTED
)
/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#UserDataHandler
*/
// Introduced in DOM Level 3
type UserDataHandler interface {
	Handle(operation uint16, key string, data DOMUserData, src Node, dest Node)
}

// ErrorSeverity
const (
	SEVERITY_WARNING = iota + 1
	SEVERITY_ERROR
	SEVERITY_FATAL_ERROR
)
/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ERROR-Interfaces-DOMError
*/
// Introduced in DOM Level 3
type DOMError interface {
	Severity() uint16
	Message() string
	Type() string
	RelatedException() DOMObject
	RelatedData() DOMObject
	Location() DOMLocator
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ERROR-Interfaces-DOMErrorHandler
*/
// Introduced in DOM Level 3
type DOMErrorHandler interface {
	HandleError(error DOMError) bool
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Interfaces-DOMLocator
*/
type DOMLocator interface {
	LineNumber() uint64
	ColumnNumber() uint64
	ByteOffset() uint64
	Utf16Offset() uint64
	RelatedNode() Node
	Uri() string
}

/*
see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMConfiguration
*/
// Introduced in DOM level 3
type DOMConfiguration interface {
	SetParameter(name string, value DOMUserData) DOMException
	GetParameter(name string) DOMUserData
	CanSetParameter(name string, value DOMException) bool
	ParameterNames() DOMStringList
}
